
/* 

Paper: Gentrification and pioneer businesses 
Authors: Behrens, Boulam, Martin, Mayneris 

Name dofile: identify_pioneers_blkgr.do  
Version: 12 nov. 2021 

Output: dataset pioneers_final_blkgr.dta with the baseline list of pioneer sectors  

Inputs:

 - pioneer_gentri90_blkgr_negbin_`v'_1990.dta with v in {pc, sh_edu, gentri} [produced in compute_elasticity_negbinblkgp] [publicly available]

*/ 

foreach v in "pc" "sh_edu" {
	use pioneer_gentri90_blkgrp_negbin_`v'.dta, clear

	// we generate dummies for significance of coefficients
	g siginit=abs(coef_`v'_gr1990_poor/se_`v'_gr1990_poor)>2.576&coef_`v'_gr1990_poor!=.
	g siginit_pcinc=abs(coef_poor1990/ se_poor1990)>2.576&coef_poor1990!=.
		
	// we create dummies for pioneers 
	gen pioneer_`v'_high= (coef_poor1990<0&siginit_pcinc==1&coef_`v'_gr1990_poor>0&siginit==1)
	saveold pioneers_blkgrp_negbin_`v'.dta, replace
		}
	
	use pioneer_gentri90_blkgrp_negbin_gentri.dta, clear
	
	// we generate dummies for significance of coefficients
	g siginit=abs(coef_gentri_9000/se_gentri_9000)>2.576&coef_gentri_9000!=.
	g siginit_pcinc=abs(coef_poor1990/ se_poor1990)>2.576&coef_poor1990!=.
		
	// we create dummies for pioneers 
	gen pioneer_gentri_high= (coef_poor1990<0&siginit_pcinc==1&coef_gentri_9000>0&siginit==1)
	save pioneers_blkgrp_negbin_gentri.dta, replace

	// we define as pioneer sectors that appear as such for at least 5 out of the 9 estimations
	use pioneers_blkgrp_negbin_pc.dta, clear
	merge 1:1 naics using pioneers_blkgrp_negbin_sh_edu.dta
	drop _m
	merge 1:1 naics using pioneers_blkgrp_negbin_gentri.dta
	drop _m
	gen var_pioneer_high=pioneer_pc_high+pioneer_sh_edu_high+pioneer_gentri_high
	gen pioneer_high_negbin_blkgrp= (var_pioneer_high>1&var_pioneer_high!=.)
	keep naics* pioneer_high_negbin_blkgrp 
	label var pioneer_high_negbin_blkgrp "Dummy is 1 if the sector is pioneer (block group)" 
	save pioneers_final_negbin_blkgrp.dta, replace	

	
	
	
	